-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use linked resource instead of filesystem #2658
base: master
Are you sure you want to change the base?
Conversation
A while ago we had a discussion where you mentioned that |
I'm looking at the tests; however, it looks like it's not allowed to put linked resources under |
your code only handles the case of projects that are automatically created by jdt.ls (default and invisible). Buildship or m2e would still create the eclipse config files in the source folder, on import, without the FS trick. Unless there's a simple way to workaround that problem, I don't see linked resources as a viable solution. |
OK, I see. I guess the importer can be reworked to first create the Java project, using |
5b73422
to
853e6e5
Compare
98a4eb6
to
02b875a
Compare
cb10a2b
to
f89ed19
Compare
8b5604d
to
0dd82bd
Compare
80e718d
to
711168f
Compare
480faf8
to
fae8c0e
Compare
fae8c0e
to
a0d6f72
Compare
I will try to investigate how this works or not with Bazel support ( redhat-developer/vscode-java#909 (comment) ) |
It looks like vscode-java-bazel already puts eclipse metadata into a |
It would be nice if this could be revisited sometimes. Working without the URI hacks would close the doors to many potential bugs. |
@jdneo do you think you might have time to look here. I see this is completely removing the |
27f6734
to
00b2937
Compare
I guess it's a Windows issue. I tried using We may also want to track if it happens that the linked resources are failed to be established. Will all thrown exception be sent as telemetry? This is a question to @rgrunber and @testforstephen |
00b2937
to
0740db9
Compare
Thanks for the tip, I've changed the code to use it. |
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/LinkResourceUtil.java
Show resolved
Hide resolved
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/LinkResourceUtil.java
Outdated
Show resolved
Hide resolved
0740db9
to
1d172c7
Compare
There is an error in the log when import a workspace for the first time in the debug mode:
Not sure if this is related with my dev environment or it is an issue. |
Can you please describe the exact steps to reproduce this issue? Do you think it can be captured in a unit test? |
Sure.
|
Good news: I can reproduce it with a test, I'll just add a log listener to capture the issue so it may fail the test. |
1d172c7
to
ef20a90
Compare
@jdneo I have added a check for this issue and fixed it. |
@mickaelistria Found a new issue on a MacOS machine today when I tried this PR. I think the root cause is that the accuracy of Below are what I observed.
|
ef20a90
to
3dfddaf
Compare
Thanks for the test and report analysis @jdneo ! |
It's working on my Mac now. Though, I'm not sure only comparing on second is safe enough. Because 1 second can really do so many things for a computer. Not to mention that the hardware will be more powerful as the time goes by. |
I don't see a way to go reliably under the precision of |
3dfddaf
to
f2d66aa
Compare
I tried something else; dynamically looking at accuracy. Can you please check whether it works on macOS? If it does, then I think it's a good enough fix; that will scale when macOS filesystem gets better precision. |
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/LinkResourceUtil.java
Outdated
Show resolved
Hide resolved
8a3d0e7
to
e608650
Compare
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/LinkResourceUtil.java
Outdated
Show resolved
Hide resolved
e608650
to
100c00e
Compare
ChronoUnit smallestSupportedUnit = Stream.of(ChronoUnit.NANOS, ChronoUnit.MILLIS, ChronoUnit.SECONDS) // IMPORTANT: keeps units in Stream from finer to coarser | ||
.filter(creationInstant::isSupported).filter(instant::isSupported) // | ||
.findFirst().orElse(null); | ||
if (smallestSupportedUnit != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check on MacOS today, looks like we still have the problem here.
smallestSupportedUnit
is assigned to ChronoUnit.NANOS
, though the accuracy of creationInstant
is second, makes this method returns false
finally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK thanks, so should we just hardcode the rule for macOS to trim to the second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so. I couldn't think of any better solution for this case.
(I was thinking about find out all the already existing metadata files before import started, but that may have too much perf penalty and may be not worth it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about find out all the already existing metadata files before import started, but that may have too much perf penalty and may be not worth it.
The difficulty here is that we don't know at that stage what folders the importers are going to consider as projects, so we're not sure which files matter or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you can just those files start from rootPaths
, because all the metadata files that exist before import happens will not be linked, so we don't need to care about what folders will be imported by which importers.
I'm not optimistic about the performance though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean recursively crawling the whole subtrees under rootPAths for pre-existing .classpath
, .project
and so on?
Indeed, it could impact heavily performance for users using the wrong root (eg their home or filesystem root), but for a regular development project, it should be fast enough (I don't expect it to take more than 1 seconds for the biggest projects). But if we're ready to loose 1 second, we can just put a 1 second wait directly after Instant.now
, and the check will then be reliable on all OSs ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new patch, I've hardcoded that Instant should be truncated and compared by the second on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we're ready to loose 1 second, we can just put a 1 second wait directly after Instant.now , and the check will then be reliable on all OSs
That's a good insight! I think there are some key metrics we need to track when roll out this change. Then we can make the decision based on the data, like:
- how many users happen to meet the two equally instants on second during import.
- how many users fail to link the files.
For example, if the data shows that very few users have two equally instant on second, then we can just simply trim to the second.
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/LinkResourceUtil.java
Show resolved
Hide resolved
Use linked resources instead of filesystem hack as this one can return invalid locations through standard API. This removes the filesystem bundle, the logic is now moved in ProjectManagers and a workspace listener takes care of using linked resources for metadata. This also remove the InvisibleProjectMetadataTest.testMetadataFileLocation() test because creating a new project in Eclipse workspace now enforces creation of a .settings/org.eclipse.core.resources.prefs file. Where the metadata for the invisible project is stored doesn't matter as the internal project is internal and not visible to user anyway.
100c00e
to
633da38
Compare
I'm thinking about this case that this solution might not be able to handle:
|
For all metadata files, except the .project (which may be harder to move).
This also copies some logic from the filesystem to ProjectsManager. We cannot have the filesystem bundle requiring and referencing the main jdt.ls bundle as this would cause classloading error.